<?php
	class newsourceControl extends commonControl{
	//主页面；	
		function index(){
			$db = M("source");
			$source = $db ->field("sname,url,sid")->findall();
			$this->assign("source",$source);
			$count = $db -> field("sid")->count();
			$page = new page($count,5);
			$row = $db->limit($page->limit())->order("sid desc")->all();
			$this->assign("row",$row);
			$this->assign("page",$page->show(2));
			$this->display();
		}
	//显示添加页面；
		function add_show(){
			$this->display();
		}
	//添加过程；
		function add(){
			$db = M("source");
			if($db->add()){
				$this->success("添加来源成功","index");
			}else{
				$this->error("添加来源失败喽！","index");
			}
		}
	//显示编织页面；
		function edit_show(){
			$sid=$_GET["sid"];
			$db = M("source");
			$res = $db -> find("sid='$sid'");
			$this->assign("res",$res);
			$this->display();
		}
	//编辑过程；
		function edit(){
			$db = M("source");
			if($db -> save()){
				$this->success("来源更改已成功","index");
			}else{
				$this->error("来源更改已失败","index");
			}
		}
	//删除一条记录；
		function del(){
			$db = M("source");
			$sid = $_GET['sid'];;
			if($db->del("sid='$sid'")){
				$this->success("删除已成功","index");
			}else{
				$this->error("删除失败","index");
			}
		}
	//删除选中的全部；
		function del_sel_all(){
			$db=M("source");
			$sid = array_keys($_POST["del"]);
			if($db->in($sid)->del()){
				$this->success("删除已成功","index");
			}else{
				$this->error("删除失败","index");
			}
		}
	}
?>